package cn.mafangui.hotel.exception;

import cn.mafangui.hotel.response.AjaxResult;
import cn.mafangui.hotel.response.ResponseTool;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author kalpa
 * @date 2022/3/17 15:34
 * @description
 */
@ControllerAdvice
public class ExcepitonHandler {

    /**
     * 处理该系统可能抛出的异常
     * @param e
     * @return
     */
    @ExceptionHandler(HotelException.class)
    @ResponseBody
    public AjaxResult hotelExcepiton(HotelException e){
        return ResponseTool.failed(e.getExceptionEnum());
    }
}
